// 天窗作业情况 - 饼状图
export function PieChart(myChart) {
  myChart.clear();
  myChart.setOption({
    tooltip: {
      trigger: 'item'
    },
    legend: {
      bottom: '15%',
      itemWidth: 18,
      itemHeight: 10,
      itemGap: 35,
      left: 'center',
      textStyle: {
        color: '#ffffff',
        fontSize: '14px'
      }
    },
    series: [
      {
        clockwise: false,
        center: ['50%', '40%'],
        name: '天窗作业情况',
        type: 'pie',
        radius: ['35%', '80%'],
        avoidLabelOverlap: false,
        label: {
          normal: {
            show: true,
            position: 'inner',
            textStyle: {
              fontSize: 18,
              color: '#000000'
            },
            formatter: '{d}%'
          }
        },
        labelLine: {
          show: false
        },
        data: [
          { value: 40, name: '进行中', itemStyle: { color: '#eaad1a' }},
          { value: 60, name: '已完成', itemStyle: { color: '#01a8f3' }}
        ]
      }
    ]
  });

  // 解决自适应
  setTimeout(function() {
    window.addEventListener('resize', () => {
      myChart.resize();
    });
  }, 500);
}
